import {Pattern} from "@/utils/validate";

export const userInfo = {
    label: '个人信息',
    prop: 'info',
    column: [{
        label: '头像',
        type: 'upload',
        listType: 'picture-img',
        propsHttp: {
            res: 'data',
            url: 'link',
        },
        canvasOption: {
            text: ' ',
            ratio: 0.1
        },
        action: '/api/blade-resource/oss/endpoint/put-file',
        tip: '只能上传jpg/png用户头像，且不超过500kb',
        span: 12,
        row: true,
        prop: 'avatar'
    }, {
        label: '姓名',
        span: 12,
        row: true,
        prop: 'realName',
        rules: [{
            required: true,
            message: "请输入姓名",
            trigger: "blur"
        }]
    }, {
        label: '用户名',
        span: 12,
        row: true,
        prop: 'name'
    }, {
        label: '手机号',
        span: 12,
        row: true,
        prop: 'phone',
        rules: [{
            required: true,
            message: "请输入手机号",
            trigger: "blur"
        }, {
            pattern: Pattern.mobile,
            message: "格式不正确",
            trigger: "blur"
        }]
    }, {
        label: '邮箱',
        prop: 'email',
        span: 12,
        row: true,
        rules: [{
            required: true,
            message: "请输入邮箱",
            trigger: "blur"
        }, {
            pattern: Pattern.email,
            message: "格式不正确",
            trigger: "blur"
        }]
    }]
};
export const password = {
    label: '',
    prop: 'password',
    column: [{
        label: '原密码',
        span: 12,
        row: true,
        type: 'password',
        prop: 'oldPassword',
        rules: [{
            required: true,
            message: "请输入原密码",
            trigger: "blur"
        }]
    }, {
        label: '新密码',
        span: 12,
        row: true,
        type: 'password',
        prop: 'newPassword',
        rules: [{
            required: true,
            message: "请输入新密码",
            trigger: "blur"
        }, {
            pattern: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\W])[\da-zA-Z\W]{8,}$/, //大小写字母，数字，符号
            message: "密码必须包含大小写字母，数字以及符号，长度不小于8",
            trigger: "blur"
        }],
    }, {
        label: '确认密码',
        span: 12,
        row: true,
        type: 'password',
        prop: 'newPassword1',
        rules: [{
            required: true,
            message: "请输入确认密码",
            trigger: "blur"
        }, {
            required: true,
            validator: (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请再次输入密码'));
                } else if (value !== this.updateForm.newPassword) {
                    callback(new Error('两次输入密码不一致!'));
                } else {
                    callback();
                }
            },
            trigger: "blur"
        }]
    }]
};
export const option = {
    // tabs: true,
    // tabsActive: 1,
    column: [{
        label: '头像',
        type: 'upload',
        listType: 'picture-img',
        propsHttp: {
            res: 'data',
            url: 'url',
        },
        canvasOption: {
            text: ' ',
            ratio: 0.1
        },
        action: '/api/blade-resource/file/uploadImg',
        tip: '只能上传jpg/png用户头像，且不超过500kb',
        span: 12,
        row: true,
        prop: 'avatar'
    }, {
        label: '姓名',
        span: 12,
        row: true,
        prop: 'realName',
        rules: [{
            required: true,
            message: "请输入姓名",
            trigger: "blur"
        }]
    }, {
        label: '用户名',
        span: 12,
        row: true,
        prop: 'name'
    }, {
        label: '手机号',
        span: 12,
        row: true,
        prop: 'phone',
        rules: [{
            required: true,
            message: "请输入手机号",
            trigger: "blur"
        }, {
            pattern: Pattern.mobile,
            message: "格式不正确",
            trigger: "blur"
        }]
    }, {
        label: '邮箱',
        prop: 'email',
        span: 12,
        row: true,
        rules: [{
            required: true,
            message: "请输入邮箱",
            trigger: "blur"
        }, {
            pattern: Pattern.email,
            message: "格式不正确",
            trigger: "blur"
        }]
    }, {
        label: '原密码',
        span: 12,
        row: true,
        type: 'password',
        prop: 'oldPassword',
        display: false
    }, {
        label: '新密码',
        span: 12,
        row: true,
        type: 'password',
        prop: 'newPassword',
        display: false
    }, {
        label: '确认密码',
        span: 12,
        row: true,
        type: 'password',
        prop: 'confirmPassword',
        display: false
    }]
};
